package org.example.controller;


import org.example.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.example.ResultMap;

@RestController
@RequestMapping("provider")
public class ClientController {

    @Autowired
    ResultMap resultMap;

    @RequestMapping("/service1/{name}/{age}")
    public ResultMap<String> service1(@PathVariable("name") String name,
                                      @PathVariable("age") int age) throws Exception {
        resultMap.setCode(200);
        resultMap.setMsg("eureka-client 7000");
        User user =new User();
        user.setUserName(name);
        if (age>100)
        {
            throw  new Exception("年龄有误！");
        }
        user.setAge(age);
        resultMap.setResult(user);
        return resultMap;
    }

}
